<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>漫画</title>
    <link rel="stylesheet" href="../css/bootstrap-theme.min.css"/>
    <link rel="stylesheet" href="../css/bootstrap.min.css"/>
    <style>
        img{
            width: 200px;
            height: 100px;
        }
        .th1{
            width:200px;
            font-family: 宋体;
            text-align: center;
        }
        .th2{
            width:300px;
            font-family: 宋体;
            text-align: center;
        }
         .th3{
            width:60px;
            font-family: 宋体;
            text-align: center;
        }
        .btn-primary{
            float:left;
            margin-left: 350px;
            margin-right: 115px;
        }
        .input-group{
            float:right;

        }
        .input-group-btn{
            display: block;
            margin-right: 0px;
            width:400px;
        }
        .table-bordered td,.table-bordered th{
            border:2px solid #5bc0de!important
        }
    </style>
</head>
<body>

<!--<div class="title1">漫画内容管理</div>-->
<div class="container ">
    <h3 class="title1">漫画内容管理</h3>
    <div class="page-header"></div>
    <p>
            <div class="row">
<!--                添加按钮-->
                <a href="contentAdd.php" class="btn  btn-primary">
                    <span class="glyphicon glyphicon-plus">添加</span>
                </a>
<!--                搜索框-->

                <form action="contentSearch.php" method="post">
                    <div class="col-lg-6">
                        <div class="input-group">
                            <input type="text" class="form-control" id="cname" name="proName"placeholder="输入漫画名">
                            <span class="input-group-btn">
                        <button class="btn btn-info" type="submit" >搜索</button>
                        </span>
                        </div>
                    </div>
                </form>
            </div>
    </p>

    <table class="table table-bordered">
        <thead>
        <tr>
            <th class="th3">作品ID</th>
            <th class="th3">章节序号</th>
            <th class="th2" >章节封面图片</th>
            <th class="th1">章节名称</th>
            <th class="th2">章节内容图片</th>
            <th class="th1">章节发布时间</th>
            <th class="th1">操作</th>
        </tr>
        </thead>
        <tbody>
        <?php
        $pageSize = 3;//表示每页有多少条记录
        $pageindex = 0;//定义一个变量，表示第几页，第一页为0
        if(!empty($_GET["pageindex"])){
            $pageindex=$_GET["pageindex"];
        }
        // 引入打开数据库的代码
        include_once dirname(__FILE__) .'../../common/conn.php';
        //执行sql命令
        $countSql = "select count(*) from content";
        $countRes = mysqli_query($con,$countSql);
        $row = mysqli_fetch_array($countRes);
        $count = $row[0];
        $offset =  $pageSize*$pageindex;//计算偏移量
        $query = "select * from content limit $offset,$pageSize";
        $res = mysqli_query($con,$query);
        //判断查询是否成功
        if($res)
        {
            while($row = mysqli_fetch_array($res))
            {
                ?>
                <tr>
                    <td class="th3"><?php echo $row["proId"] ?></td>
                    <td class="th3"><?php echo $row["section"] ?></td>
                    <td class="th2" >
                        <img src="<?php echo $row["sectionImg"] ?>" />
                    </td>
                    <td class="th1"><?php echo $row["sectionName"] ?></td>
                    <td class="th2">
                        <img src="<?php echo $row["imgUrl"] ?>" />
                    </td>
                    <td class="th1"><?php echo $row["publicTime"] ?></td>
                    <td class="th1">
                        <!-- 编辑-->
                        <a href="contentEdit.php?proId=<?php echo $row["proId"]?> && section=<?php echo $row["section"] ?>" class="btn btn-xs btn-warning">
                            <span class="glyphicon glyphicon-pencil"></span>
                        </a>
                        <!--删除-->
                        <a href="contentDelete.php?proId=<?php echo $row["proId"]?> && section=<?php echo $row["section"] ?>" class="btn btn-xs btn-warning" onClick="return confirm('确定删除?');">
                            <span class="glyphicon glyphicon-trash"></span>
                        </a>
                        <!--预览-->
                        <a href="contentView.php?proId=<?php echo $row["proId"]?> && section=<?php echo $row["section"] ?>" class="btn btn-info btn-xs">预览</a>

                    </td>
                </tr>
            <?php    }
        }
        ?>
        </tbody>
    </table>
    <nav>
        <ul class="pager">
            <li><a href="cList.php?pageindex=<?php echo $pageindex-1 <0 ? 0 :$pageindex-1?>">上一页</a></li>
            <li>总共<?php echo $count?>条消息 共<?php echo ceil($count/$pageSize)?>页</li>
            <li><a href="cList.php?pageindex=<?php echo $pageindex+1 >= ceil($count/$pageSize) ? ceil($count/$pageSize)-1:$pageindex+1?>">下一页</a></li>
        </ul>
    </nav>
    </div>
</div>
</body>
</html>